package sample.dubbo.export;

import java.util.concurrent.CountDownLatch;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.ServiceConfig;

/**
 * Created on 2020/7/28
 */
public class ExportSample {

	public interface FooService {
		void doFoo();
	}

	public static class FooServiceImpl implements FooService {

		public void doFoo() {

		}
	}

	public static void main(String[] args) throws InterruptedException {
		ApplicationConfig appConfig = new ApplicationConfig();
		appConfig.setName("export-sample");
		ProtocolConfig protocolConfig = new ProtocolConfig();
		protocolConfig.setName("dubbo");
		RegistryConfig registryConfig = new RegistryConfig();
		registryConfig.setAddress("multicast://224.5.6.7:1234");
		ServiceConfig serviceConfig = new ServiceConfig();
		serviceConfig.setInterface(FooService.class);
		serviceConfig.setRef(new FooServiceImpl());
		serviceConfig.setApplication(appConfig);
		serviceConfig.setProtocol(protocolConfig);
		serviceConfig.setRegistry(registryConfig);
		serviceConfig.export();

		new CountDownLatch(1).await();
	}
}
